#ifndef _H_CPPTHREAD
#define _H_CPPTHREAD

#include "pthread.h"

class cppthread_t{

    protected:
        pthread_t thread;

    public:
        cppthread_t(void* (*)(void*), void* = NULL, pthread_attr_t* = NULL);
        ~cppthread_t();

        void* join();
        void cancel();

};

class cppthread_mutex_t{

    protected:
        pthread_mutex_t mutex;

    public:
        cppthread_mutex_t();
        ~cppthread_mutex_t();

        void lock();
        bool trylock();
        bool timedlock(const struct timespec * );
        void unlock();

};

class cppthread_cond_t{

    protected:
        pthread_mutex_t mutex;
        pthread_cond_t cond;

    public:
        cppthread_cond_t();
        ~cppthread_cond_t();

        void wait();
        bool timedwait(const struct timespec * );
        void signal();
        void broadcast();

};

#endif
